<?php
/**
 * alltosun.com admin_data 统计数据
 * ============================================================================
 * 版权所有 (C) 2009-2011 北京互动阳光科技有限公司，并保留所有权利。
 * 网站地址: http://www.alltosun.com
 * ----------------------------------------------------------------------------
 * 许可声明：这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
 * ============================================================================
 * $Author: 高昂 (gaoa@alltosun.com) $
 * $Date: 2016-4-6 下午5:58:21 $
 * $Id: $
 */

class new_admin_data_helper
{
    private $enable_user_ids = array();
    private $enable_store_ids = array();

    /**
     * 获取设备绑定信息
     */
    public static function get_device_record_list()
    {
        // 获取所有已经绑定的保温箱码和广告机码
        $machine_no_list = device_helper::get_device_no_list_by_type('MX');
        $adbox_no_list   = device_helper::get_device_no_list_by_type('AD');

        $long_list  = array();
        $short_list = array();
        $long_type  = '';
        $short_type = '';

        if (count($machine_no_list) >= count($adbox_no_list)) {
            $long_list  = $machine_no_list;
            $short_list = $adbox_no_list;
            $long_type  = 'machine';
            $short_type = 'adbox';
        } else {
            $long_list  = $adbox_no_list;
            $short_list = $machine_no_list;
            $long_type  = 'adbox';
            $short_type = 'machine';
        }
        $device_list = array();
        if ($long_list) {
            foreach ($long_list as $k => $v) {
                $long_store_device_relation = device_helper::get_store_device_relation($v['id']);
                if (!$long_store_device_relation) {
                    // 如果找不到设备绑定信息跳出
                    unset($long_list[$k]);
                    continue;
                }

                if ($long_store_device_relation['add_time'] > date('Y-m-d').' 00:00:00') {
                    continue;
                }

                $long_store_info = store_helper::get_store($long_store_device_relation['store_id']);
                if (!$long_store_info) {
                    // 如果找不到门店信息
                    // unset($long_list[$k]);
                    continue;
                }
                $long_dealer_info = user_helper::get_user_info($long_store_info['agency_id']);

                if (1 == $long_store_info['is_enable'] && 1 == $long_store_info['is_delete'] && 1 == $long_dealer_info['is_enable'] && 1 == $long_dealer_info['status']) {
                    if (!$long_store_device_relation || !$long_store_info || !$long_dealer_info) {
                        // 如果找不到商店信息可能是商店被删除了
                        unset($long_list[$k]);
                        continue;
                    }

                    $device_list[$k][$long_type.'_add_time']   = substr($long_store_device_relation['add_time'], 0, 10);
                    $device_list[$k][$long_type.'_device_no']  = $v[$long_type.'_no'];
                    $device_list[$k][$long_type.'_status']     = '已绑定';
                    $device_list[$k][$long_type.'_store_name'] = $long_store_info['title'].$long_store_info['title_branch'];
                    $device_list[$k][$long_type.'_dealer_name'] = $long_dealer_info['realname'];
                    $device_list[$k][$long_type.'_bind_time']  = $long_store_device_relation['add_time'];
                    $device_list[$k][$short_type.'_add_time']    = '';
                    $device_list[$k][$short_type.'_device_no']   = '';
                    $device_list[$k][$short_type.'_status']      = '';
                    $device_list[$k][$short_type.'_store_name']  = '';
                    $device_list[$k][$short_type.'_dealer_name'] = '';
                    $device_list[$k][$short_type.'_bind_time']   = '';
                }
            }
        }
        if ($short_list) {
            foreach ($short_list as $k => $v) {
                $short_store_device_relation = device_helper::get_store_device_relation($short_list[$k]['id']);
                $short_store_info = store_helper::get_store($short_store_device_relation['store_id']);
                $short_dealer_info = user_helper::get_user_info($short_store_info['agency_id']);

                if (1 == $long_store_info['is_enable'] && 1 == $long_store_info['is_delete'] && 1 == $long_dealer_info['is_enable'] && 1 == $long_dealer_info['status']) {
                    if (!$short_store_device_relation || !$short_store_info || !$short_dealer_info) {
                        // 如果找不到商店信息可能是商店被删除了
                        unset($short_list[$k]);
                        continue;
                    }

                    if ($short_store_device_relation['add_time'] > date('Y-m-d').' 00:00:00') {
                        continue;
                    }

                    $device_list[$k][$short_type.'_add_time']    = $short_store_device_relation['add_time'];
                    $device_list[$k][$short_type.'_device_no']   = $short_list[$k][$short_type.'_no'];
                    $device_list[$k][$short_type.'_status']      = '已绑定';
                    $device_list[$k][$short_type.'_store_name']  = $short_store_info['title'].$short_store_info['title_branch'];
                    $device_list[$k][$short_type.'_dealer_name'] = $short_dealer_info['realname'];
                    $device_list[$k][$short_type.'_bind_time']   = $short_store_device_relation['add_time'];
                }
            }
        }

        return $device_list;

    }


    /**
     * 获取商家明细
     */
    public static function get_store_data_list()
    {
        $store_list = array();

        $filter['is_enable'] = 1;
        $filter['is_delete'] = 1;
        $filter['`agency_id` != '] = 0;
        $filter['`add_time` < '] = date('Y-m-d').' 00:00:00';

        $store_list = _model('store')->getList($filter, ' ORDER BY `id` DESC');
        if ($store_list) {
            $type_arr = store_config::$type_arr;
            foreach ($store_list as $k => $v) {
                if (!$v['sign_user_id']) {
                    continue;
                }
                $sign_user_role_id = user_helper::get_user_role_id($v['sign_user_id']);
                $sign_user_info = user_helper::get_user_info($v['sign_user_id']);
                $dealer_user_info = user_helper::get_user_info($v['agency_id']);
                if (!$sign_user_info) {
                    // unset($store_list[$k]);
                    // 如果找不到签约人,则默认使用合伙人的信息
                    $sign_user_info = $dealer_user_info;
                }

                if (!$dealer_user_info) {
                    // unset($store_list[$k]);
                    continue;
                }

                $user_info = _uri('user', @$v['owner_id']);

                if ($user_info) {
                    $store_list[$k]['user_name'] = $user_info['user_name'];
                    $store_list[$k]['mobile']    = $user_info['mobile'];
                }
                if (isset($type_arr[$v['type']])) {
                    $store_list[$k]['type_name']  = $type_arr[$v['type']];
                }
                if ($v['agency_id']) {
                    $dealer_info = _uri('user', $v['agency_id']);
                    if ($dealer_info) {
                        $store_list[$k]['dealer_name'] = $dealer_info['realname'];
                        $store_list[$k]['dealer_mobile'] = $dealer_info['mobile'];
                    }
                }

                $store_list[$k]['sign_user_type'] = user_config::$role_arr[$sign_user_role_id];
                $store_list[$k]['sign_user_role_id'] = user_config::$role_arr[$sign_user_role_id];
                $store_list[$k]['sign_user_info'] = $sign_user_info;
                $store_list[$k]['sign_user'] = $sign_user_info['realname'].'（'.$store_list[$k]['sign_user_type'].'）';

                // 是否进货及进货额度
                $store_list[$k]['is_ever_stock'] = store_helper::get_store_stock_money($v['id'], 10);
                $store_list[$k]['stock_num']     = 0;
                if ($store_list[$k]['is_ever_stock']) {
                    $store_list[$k]['stock_num']     = $store_list[$k]['is_ever_stock'].'箱';
                    $store_list[$k]['is_ever_stock'] = '是';
                } else {
                    $store_list[$k]['is_ever_stock'] = '否';
                    $store_list[$k]['stock_num'] = '0箱';
                }
                $store_list[$k]['store_title']       = $store_list[$k]['title'].$store_list[$k]['title_branch'];
                $store_list[$k]['store_stock_money'] = store_helper::get_store_stock_money($v['id']);
                $store_list[$k]['store_type']        = store_config::$type_arr[$v['type']];
                if ($v['status'] == 1) {
                    $store_list[$k]['store_status'] = '未审核';
                } elseif ($v['status'] == 2) {
                    $store_list[$k]['store_status'] = '正常营业';
                } else {
                    $store_list[$k]['store_status'] = '已撤店';
                }

                // 所属合伙人
                $store_list[$k]['dealer_name'] = $dealer_user_info['realname'];

                // 是否绑定设备
                $is_bind_device = device_helper::is_bind_device($v['id']);
                if ($is_bind_device) {
                    $store_list[$k]['is_bind_device'] = '是';
                } else {
                    $store_list[$k]['is_bind_device'] = '否';
                }

            }
        }

        return $store_list;
    }


    /**
     * 获取合伙人明细
     */
    public static function get_dealer_info_list()
    {
        $enable_user_ids = _model('user')->getFields('id', array('is_enable' => 1, 'status' => 1, '`add_time` <= '=>date('Y-m-d H:i:s').' 23:59:59'));
//         $this->enable_store_ids = _model('store')->getFields('id', array('is_enable' => 1, 'is_delete' => 1, '`add_time` <= '=>date('Y-m-d H:i:s').' 23:59:59'));


        // 获取所有有效的合伙人
        $dealer_ids = user_helper::get_role_user_ids(user_config::AGENCY, '', array('is_enable' => 1, 'status' => 1));
        if (!$dealer_ids) {
            return array();
        }

        $dealer_list = array();
        foreach ($dealer_ids as $k => $v) {
            $cur_dealer_info = user_helper::get_user_info($v);
            //             if (!$cur_dealer_info) {
            //                 // unset($dealer_ids[$k]);
            //                 continue;
            //             }
            // 日期
            $dealer_list[$k] = array();
            $dealer_list[$k]['dealer_id'] = $cur_dealer_info['id'];
            $dealer_list[$k]['add_time'] = $cur_dealer_info['add_time'];
            // 新增合伙人姓名
            $dealer_list[$k]['dealer_name'] = $cur_dealer_info['realname'] ? $cur_dealer_info['realname'] : $cur_dealer_info['nickname'];
            // 电话
            $dealer_list[$k]['dealer_mobile'] = ' '.$cur_dealer_info['mobile'].' ';
            // 是否创建库存 @TODO
            $dealer_list[$k]['is_create_stock'] = ' ';
            // 掌柜数量
            $store_list = store_helper::get_store_list_by_dealer_id($cur_dealer_info['id'], array('is_enable' => 1, 'is_delete'=>1, 'status' => array(1, 2)));
            $dealer_list[$k]['store_num'] = count($store_list);
            // 是否创建掌柜
            if ($store_list) {
                $dealer_list[$k]['is_sign_store'] = '是';

                $bind_device_num = 0;
                $marketing_list  = array();
                $marketing_num   = 0;
                $is_sign_marketing = '否';
                foreach ($store_list as $key => $val) {
                    if (0 != $val['marketing_id'] && $val['marketing_id'] != $val['agency_id'] && !in_array($val['marketing_id'], $marketing_list)) {
                        array_push($marketing_list, $val['marketing_id']);
                    }
                    $marketing_num = count($marketing_list);
                    if ($marketing_num) {
                        $is_sign_marketing = '是';
                    } else {
                        $is_sign_marketing = '否';
                    }
                    $cur_device_num = 0;
                    // 当天店铺的绑定设备数
                    $cur_device_num = device_helper::get_bind_device_type_count_by_store_id($val['id']);
                    $bind_device_num += $cur_device_num;
                }

                // 员工数量
                $dealer_list[$k]['marketing_num'] = _model('user_marketing')->getTotal(array('agency_id'=>$v, 'marketing_id'=>$enable_user_ids));
                if ($dealer_list[$k]['marketing_num']) {
                    $is_sign_marketing = '是';
                } else {
                    $is_sign_marketing = '否';
                }
                // 是否创建员工
                $dealer_list[$k]['is_sign_marketing'] = $is_sign_marketing;

                // 绑定设备数量
                $dealer_list[$k]['bind_device_num'] = $bind_device_num;
            } else {
                $dealer_list[$k]['is_sign_store'] = '否';
                // 是否创建员工
                $dealer_list[$k]['is_sign_marketing'] = '否';
                // 员工数量
                $dealer_list[$k]['marketing_num'] = '0';
                // 绑定设备数量
                $dealer_list[$k]['bind_device_num'] = '0';
            }

            // 下单数量 (是要是收款的订单就算)
            $dealer_list[$k]['dealer_order_num'] = order_helper::get_order_num_by_progress(array(3, 5, 10) , 1, array('user_id' => $cur_dealer_info['id'], 'is_enable' => 1, 'status' => 1));
            // 是否下单
            if ($dealer_list[$k]['dealer_order_num']) {
                $dealer_list[$k]['is_ever_order_goods'] = '是';
            } else {
                $dealer_list[$k]['is_ever_order_goods'] = '否';
            }

            // 待收款
            $dealer_list[$k]['prepare_pay_order_num']      = order_helper::get_order_num_by_progress(1 , 1, array('user_id' => $cur_dealer_info['id'], 'is_enable' => 1, 'status' => 1));;
            // 待配送
            $dealer_list[$k]['prepare_delivery_order_num'] = order_helper::get_order_num_by_progress(3 , 1, array('user_id' => $cur_dealer_info['id'], 'is_enable' => 1, 'status' => 1));;
            // 配送中
            $dealer_list[$k]['in_delivery_order_num']      = order_helper::get_order_num_by_progress(5 , 1, array('user_id' => $cur_dealer_info['id'], 'is_enable' => 1, 'status' => 1));;
            // 配送完成
            $dealer_list[$k]['finish_delivery_order_num']  = order_helper::get_order_num_by_progress(10 , 1, array('user_id' => $cur_dealer_info['id'], 'is_enable' => 1, 'status' => 1));;
            // 撤销订单
            $dealer_list[$k]['dealer_cancel_order_num']    = order_helper::get_order_num_by_progress(15 , 1, array('user_id' => $cur_dealer_info['id'], 'is_enable' => 1, 'status' => 1));;
        }

        return $dealer_list;
    }



    /**
     * 获取指定一天的统计数据(新)
     * @param unknown $time 时间戳
     * @return number
     */
    public static function new_get_admin_data($time = '')
    {
        if (!$time)  $time = strtotime('-1 day');

        $cur_day_filter = array('`add_time` > '=>date('Y-m-d', $time).' 00:00:00', '`add_time` <= '=>date('Y-m-d', $time).' 23:59:59');
        $pre_day_filter = array('`add_time` <= '=>date('Y-m-d', $time).' 23:59:59');

        $admin_data_list = array();

        /**
         * 合伙人数据
         */
        // 获取有效的合伙人id(累计)
        $enable_dealers_ids = _model('user')->getFields('id', array(
            'is_enable'         => 1,
            '`dealer_level` > ' => 0,
            'status'            => 1,
            '`add_time` <= '    => date('Y-m-d', $time).' 23:59:59'
        ));

        // 获取有效的市场人员id(累计)
        $user_marketing_ids = _model('user_marketing')->getFields('marketing_id', array(
            'status'         => 1,
            'is_delete'      => 1,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59'
        ));
        $enable_marketing_ids = _model('user')->getFields('id', array(
            'is_enable'      => 1,
            'status'         => 1,
            'id'             => $user_marketing_ids,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59'
        ));

        // 获取有效的合伙人id(当天)
        $today_enable_dealers_ids = _model('user')->getFields('id', array(
            'is_enable'         => 1,
            '`dealer_level` > ' => 0,
            'status'            => 1,
            '`add_time` > '     =>date('Y-m-d', $time).' 00:00:00',
            '`add_time` <= '    =>date('Y-m-d', $time).' 23:59:59'
        ));

        // 获取有效的市场人员id(当天)
        $today_user_marketing_ids = _model('user_marketing')->getFields('marketing_id', array(
            'status'         => 1,
            'is_delete'      => 1,
            '`add_time` > '  => date('Y-m-d', $time).' 00:00:00',
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59'
        ));
        $today_enable_marketing_ids = _model('user')->getFields('id', array('is_enable'=>1, 'status'=>1, 'id'=>$today_user_marketing_ids, '`add_time` > '=>date('Y-m-d', $time).' 00:00:00', '`add_time` <= '=>date('Y-m-d', $time).' 23:59:59'));

        // 有效订单的状态值
        $enable_order_progress = array(3, 5, 10);

        // 有效门店状态
        $enable_store_status = array(store_config::STATUS_TRIAL, store_config::STATUS_NORMAL);

        // 无效门店状态
        $unable_store_status = array(store_config::STATUS_STOP, store_config::STATUS_DELETE);

        // 无效的店铺id
        $unable_store_ids = _model('store')->getFields('id', array(
            'status'         => $unable_store_status,
            'is_delete'      => 0,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59'
        ));

        // 有效的分店id
        $enable_store_ids = _model('store')->getFields('id', array(
            'status'         => $enable_store_status,
            'is_delete'      => 1,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59'
        ));

        // 日期

        // 新增合伙人
        $admin_data_list['today_add_dealer_num'] = count($today_enable_dealers_ids);

        // 合伙人总量
        $admin_data_list['dealer_num'] = count($enable_dealers_ids);

        // 已下单合伙人数
        $admin_data_list['with_order_dealer_num'] = _model('order')->getTotal(array(
            'user_id'       => $enable_dealers_ids,
            'type'          => 1,
            'progress'      => $enable_order_progress,
            '`add_time` <= '=> date('Y-m-d', $time).' 23:59:59'
        ), 'GROUP BY `agency_id`');

        // 已签约门店合伙人
        $admin_data_list['with_store_dealer_num'] = _model('store')->getTotal(array(
            'agency_id'     =>$enable_dealers_ids,
            'status'        => $enable_store_status,
            '`add_time` <= '=>date('Y-m-d', $time).' 23:59:59'
        ), 'GROUP BY `agency_id`');

        // 新增员工
        $admin_data_list['new_marketing_num'] = count($today_enable_marketing_ids);

        // 员工数量
        $admin_data_list['marketing_num'] = count($enable_marketing_ids);

        /**
         * 合伙人订单数据
         */
        // 新增订单
        $admin_data_list['today_dealer_new_order_num'] = order_helper::get_order_num_by_progress($enable_order_progress, 1, array(
            'agency_id' => $enable_dealers_ids,
            '`add_time` <= '=>date('Y-m-d', $time).' 23:59:59'
        ));

        //待收款
        $admin_data_list['today_prepare_pay_order_num'] = order_helper::get_order_num_by_progress(1, 1, array(
            'agency_id' => $enable_dealers_ids,
            '`add_time` <= '=>date('Y-m-d', $time).' 23:59:59'
        ));

        // 超36小时未付款订单 (假设)
        $onehalf_day = time() - 36 * 60 * 60;
        $admin_data_list['today_over_onehalf_day_not_pay_order_num'] = order_helper::get_order_num_by_progress(1, 1, array(
            'agency_id' => $enable_dealers_ids,
            // '`add_time` <= '=>date('Y-m-d', $time).' 23:59:59',
            '`add_time` <= ' => date('Y-m-d H:i:s', $onehalf_day),
        ));

        // 待配送
        $admin_data_list['today_prepare_delivery_order_num'] = order_helper::get_order_num_by_progress(array(1, 3), 1, array(
            'agency_id'      => $enable_dealers_ids,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59'
        ));

        // 配送中
        $admin_data_list['today_delivery_order_num'] = order_helper::get_order_num_by_progress(5, 1, array(
            'agency_id'      => $enable_dealers_ids,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59'
        ));

        // 配送中超七天(不含七天)订单
        $over_seven_day = time() - 7 * 24 * 60 * 60;
        $admin_data_list['today_over_seven_day_delivery_order_num'] = order_helper::get_order_num_by_progress(5, 1, array(
            'agency_id'          => $enable_dealers_ids,
            '`add_time` <= '     => date('Y-m-d', $time).' 23:59:59',
            '`deliver_time` <= ' => date('Y-m-d H:i:s', $over_seven_day)
        ));

        // 配送完成
        $admin_data_list['today_finished_order_num'] = order_helper::get_order_num_by_progress(10, 1, array(
            'agency_id'      => $enable_dealers_ids,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59'
        ));

        // 撤销订单
        $admin_data_list['today_cancel_order_num'] = order_helper::get_order_num_by_progress(15, 1, array(
            'agency_id'      => $enable_dealers_ids,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59'
        ));

        // 待配送箱数
        $order_list = _model('order')->getList(array(
            'agency_id'      => $enable_dealers_ids,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59',
            'progress'       => array(1, 3),
            'status'         => 1,
            'is_enable'      => 1
        ));
        $goods_num = 0;
        if ($order_list) {
            foreach ($order_list as $k => $v) {
                $goods_num += $v['goods_num'];
            }
        }
        $admin_data_list['today_prepare_delivery_goods_num'] = $goods_num;

        // 配送完成箱数
        $order_list = _model('order')->getList(array(
            'agency_id'      => $enable_dealers_ids,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59',
            'progress'       => 10,
            'status'         => 1,
            'is_enable'      => 1
        ));
        $goods_num = 0;
        if ($order_list) {
            foreach ($order_list as $k => $v) {
                $goods_num += $v['goods_num'];
            }
        }
        $admin_data_list['today_finished_goods_num'] = $goods_num;

        // 总库存箱数
        $admin_data_list['all_dealer_stock'] = dealers_helper::get_dealer_stock($enable_dealers_ids);


        /**
         * 店铺数据
         */
        // 掌柜数量
        $admin_data_list['all_store_num'] = store_helper::get_all_store_num(array(
            'agency_id'      => $enable_dealers_ids,
            'status'         => $enable_store_status,
            'is_delete'      => 1,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59',
        ));

        // 撤店数量
        $admin_data_list['stop_store_num'] = store_helper::get_all_store_num(array(
            'agency_id'      => $enable_dealers_ids,
            'status'         => store_config::STATUS_STOP,
            'is_delete'      => 1,
            '`add_time` <= ' => date('Y-m-d', $time).' 23:59:59',
        ));

        // 已进货门店
        $admin_data_list['is_stock_store_num'] = user_helper::get_user_num_by_role_id(user_config::STORE_MANAGER, array('`score` > '=>0, '`add_time` <= '=>date('Y-m-d', $time).' 23:59:59'));

        // 已绑定设备
        $all_is_bind_device_store_num = _model('store_device_relation')->getTotal(array(
            'status' => 2,
        ), 'GROUP BY `store_id`');
        $unable_is_bind_device_store_num = _model('store_device_relation')->getTotal(array(
            'store_id' => $unable_store_ids,
        ), 'GROUP BY `store_id`');
        $admin_data_list['is_bind_device_store_num'] = $all_is_bind_device_store_num - $unable_is_bind_device_store_num;

        // 新增掌柜
        $admin_data_list['today_new_store_num'] = user_helper::get_user_num_by_role_id(user_config::STORE_MANAGER, $cur_day_filter);

        // 箱体绑定总量
        $all_bind_device_num = _model('store_device_relation')->getTotal(array('status'=>2));
        $unable_bind_device_num = _model('store_device_relation')->getTotal(array('status'=>2, 'store_id'=>$unable_store_ids));
        $admin_data_list['all_bind_device_num'] = $all_bind_device_num - $unable_bind_device_num;

        /**
         * 店铺订单数据
         */
        // 新增订单
        $admin_data_list['today_new_store_order_num'] = order_helper::get_order_num_by_progress($enable_order_progress, 5, $cur_day_filter);

        // 配送完成
        $admin_data_list['today_finished_store_order_num'] = order_helper::get_order_num_by_progress(10, 5, $cur_day_filter);

        // 进货总量箱数
        $goods_num = 0;
        $order_list = order_helper::get_store_order_list($enable_store_ids, $cur_day_filter);
        if ($order_list) {
            foreach ($order_list as $k => $v) {
                $goods_num += $v['goods_num'];
            }
        }
        $admin_data_list['today_store_stock_goods_num'] = $goods_num;

        // 总库存箱数
        $goods_num = 0;
        $all_store_stock_goods_money = 0;
        $order_list = order_helper::get_store_order_list($enable_store_ids, $pre_day_filter);
        if ($order_list) {
            foreach ($order_list as $k => $v) {
                $goods_num += $v['goods_num'];
                $all_store_stock_goods_money += $v['price'];
            }
        }
        $admin_data_list['all_store_stock_goods_num'] = $goods_num;

        // 累计进货总额
        $admin_data_list['all_store_stock_goods_money'] = $all_store_stock_goods_money;
        echo '<pre>';
        print_r($admin_data_list);
        return $admin_data_list;
        exit;
    }
}


?>